<{include file="public/header.html"}> 
	<header class="title title-border-sm bj-white">
            <a href="javascript:;" class="icon-return iconfont title-left title-top col-red" onclick="javascript:history.go(-1);">&#xe604;</a>
		<h1 class="text-center name">修改登录密码</h1>
	</header>
        <form id="modify-form" class="plr15" data-href="<{eval url('ajax/ajax_modify_baseinfo')}>" onsubmit="return false;">
		<div class="input-group input-group-tip">
			<p>原始密码</p>
			<input type="password" name="oldPass" id="oldPass" placeholder="原登录密码" oninput="if(value.length>16)value=value.slice(0,16)" data-validate="oldpwd" data-describedby="oldpwd-description"/>
		</div>
		<div class="input-group input-group-tip">
			<p>新&nbsp;&nbsp;密&nbsp;码</p>
			<input type="password" name="newPass" id="newPass" placeholder="6~16位数字和字母组成，区分大小写" oninput="if(value.length>16)value=value.slice(0,16)" data-validate="pwd" data-describedby="pwd-description"/>
		</div>
		<div class="input-group input-group-tip">
			<p>确认密码</p>
			<input type="password" name="renewPass" id="renewPass" placeholder="确认登录密码" oninput="if(value.length>16)value=value.slice(0,16)"/>
		</div>
                <input type="submit" id="form-modify-btn" class="btn btn-yes mt10" value="确认保存"/>
	</form>
        <script type="text/javascript">
        $(function(){
            var check_flag = true,check_count = 0;
            $.mvalidateExtend({
                oldpwd:{
                    required : true,   
                    descriptions:{
                        required : '<div class="field-invalidmsg">请输入原登录密码</div>',
                    }
                },
                pwd:{
                    required : true,   
                    pattern : /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z]{1}[0-9A-Za-z]{5,16}$/,
                    each:function(){

                    },
                    descriptions:{
                        required : '<div class="field-invalidmsg">请输入新登录密码</div>',
                        pattern : '<div class="field-invalidmsg">6~16 位密码，必须由数字和字母组成，区分大小写</div>',
                    }
                }
            });
             $("#modify-form").mvalidate({
                type:1,
                onKeyup:true,
                sendForm:true,
                firstInvalidFocus:false,
                descriptions: {
                },
                valid:function(event,options){
                    if($("#oldPass").val() == ""){
                        $.mvalidateTip("请输入原始密码");return false;
                    }
                    if($("#renewPass").val() != $("#newPass").val()){
                        $.mvalidateTip("两次输入的密码不一致");return false;
                    }
                    add_check_oper_listener();
                    var url = $('#modify-form').attr("data-href");
                    check_flag = false;
                    $("#form-modify-btn").val("保存中...");
                    $.ajax({
                        type: "POST",
                        url: url,
                        async:true, 
                        data: 'setType=loginpass&newPass=' + $('#newPass').val() + "&oldPass=" + $('#oldPass').val(),
                        success: function(resp) {
                            resp = $.parseJSON(resp);
                            if(resp.reqStatus){
                                $.mvalidateTip("保存成功,2s后自动返回登录页面");
                                $("#form-modify-btn").val("确认保存");
                                $("#newPass").val("");$("#renewPass").val("");$("#oldPass").val("");
                                setTimeout(function(){
                                    window.location.href = resp.url;
                                },1500);
                            }else{
                                cancel_check_oper_listener();
                                $("#form-modify-btn").val("重新保存");
                                $.mvalidateTip(resp.errorMsg);
                                return false;
                            }
                        }
                    });
                },
                invalid:function(event, status, options){
                    //点击提交按钮时,表单未通过验证触发函数
                },
                eachField:function(event,status,options){
                    //点击提交按钮时,表单每个输入域触发这个函数 this 执向当前表单输入域，是jquery对象
                },
                eachValidField:function(val){},
                eachInvalidField:function(event, status, options){},
            })

            function add_check_oper_listener(){
                if(check_count == 2){
                    check_count = 0;
                    $.mvalidateTip("操作过于频繁");return false;
                }
                if(!check_flag){
                    check_count ++;
                    $.mvalidateTip("正在处理保存操作");return false;
                }
            };
            function cancel_check_oper_listener(){
                check_count = 0;
                check_flag = true;
            }
        });
        </script>
<{include file="public/footer.html"}> 	
